//
//  BiDocInfoManageViewController.m
//  TrunkIndustryManageSystem
//
//  Created by 李璐西 on 15/5/5.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiDocInfoManageViewController.h"

#import "BiCarLiscenceComEntity.h"
#import "BiCarLicense.h"
#import "BICarLicenseType.h"

@interface BiDocInfoManageViewController ()<UITableViewDelegate>{
    
    __weak IBOutlet UIScrollView *_ScrollView;
    
}
@property (weak, nonatomic) IBOutlet UILabel *labVin;
@property (weak, nonatomic) IBOutlet UITextView *textVReasons;
@property (weak, nonatomic) IBOutlet UILabel *labMenberName;
@property (weak, nonatomic) IBOutlet UILabel *labBusinessJiesuanMoney;
@property (weak, nonatomic) IBOutlet UILabel *labNoJiesuanMoney;
@property (weak, nonatomic) IBOutlet UILabel *labSaleAdvisorName;
@property (weak, nonatomic) IBOutlet UILabel *labRegisteTime;
@property (weak, nonatomic) IBOutlet UILabel *labValidTime;
@property (weak, nonatomic) IBOutlet UILabel *labLicensePlate;

@property (weak, nonatomic) IBOutlet UILabel *labEarnMemberPrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnCostPrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnDetectionPrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnManagementPrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnServicePrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnAgencyPrice;
@property (weak, nonatomic) IBOutlet UILabel *labEarnTotalPrice;

@property (weak, nonatomic) IBOutlet UILabel *labInfoPifuPersonName;
@property (weak, nonatomic) IBOutlet UILabel *labInfoPifuTime;

@end

@implementation BiDocInfoManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavBarWithHidden:NO];
    [self setNavBackBtn];
    [self setNavBarTitle:@"牌证信息审批"];
    
    _ScrollView.contentSize = CGSizeMake(MAIN_SCREEN_WIDTH, 1120);
    self.textVReasons.layer.borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:100.0].CGColor;
    self.textVReasons.layer.borderWidth = 0.5;
    [self dataFill];
}

- (void)dataFill {
    _textVReasons.text = self.cEntity.Carlisce.infoRejectReason;
    
    _labVin.text = self.cEntity.Carlisce.vin;
    _labMenberName.text = self.cEntity.Carlisce.memberName;
    _labBusinessJiesuanMoney.text = self.cEntity.Carlisce.businessJiesuanMoney;
    _labNoJiesuanMoney.text = self.cEntity.Carlisce.noJiesuanMoney;
    _labSaleAdvisorName.text = self.cEntity.Carlisce.saleAdvisorName;
    _labRegisteTime.text = self.cEntity.CarlisceType.registeTime;
    _labValidTime.text = self.cEntity.CarlisceType.validTime;
    _labLicensePlate.text = self.cEntity.CarlisceType.licensePlate;
    
    _labEarnMemberPrice.text = self.cEntity.CarlisceType.earnMemberPrice;
    _labEarnCostPrice.text = self.cEntity.CarlisceType.earnCostPrice;
    _labEarnDetectionPrice.text = self.cEntity.CarlisceType.earnDetectionPrice;
    _labEarnManagementPrice.text = self.cEntity.CarlisceType.earnManagementPrice;
    _labEarnServicePrice.text = self.cEntity.CarlisceType.earnServicePrice;
    _labEarnAgencyPrice.text = self.cEntity.CarlisceType.earnAgencyPrice;
    _labEarnTotalPrice.text = self.cEntity.CarlisceType.earnTotalPrice;
    
    _labInfoPifuPersonName.text = self.cEntity.Carlisce.infoPifuPersonName;
    _labInfoPifuTime.text = self.cEntity.Carlisce.infoPifuTime;
}

- (IBAction)btnCheckClick:(UIButton *)sender {
    
    NSString * stutas = nil;
    if (1 == sender.tag) {
        //批准
        stutas = @"1";
    }else if (0 == sender.tag){
        //驳回
        stutas = @"0";
    }
    
    
    //    NSString * jiaokuanPifuPersonName = !self.cEntity.Carlisce.jiaokuanPifuPersonName?@"":self.cEntity.Carlisce.jiaokuanPifuPersonName;
    
    NSString * infoRejectReason = !self.cEntity.Carlisce.infoRejectReason?@"":self.cEntity.Carlisce.infoRejectReason;
    
    NSDictionary * paraDic = nil;
    
    if (1 == sender.tag) {
        
        paraDic = @{@"id":self.cEntity.Carlisce.ID,
                    @"licenseStatus":@"5",
                    @"status":@"1"};
        
    }else if (0 == sender.tag) {
        
        paraDic = @{@"id":self.cEntity.Carlisce.ID,
                    @"licenseStatus":@"5",
                    @"status":@"0",
                    @"infoRejectReason":_textVReasons.text};
        
    }
    
    [[BiNetEngine shareInstance] requestDocInfoCheck:self paraDict:paraDic];
    
    [self asyshowHUDView:WAITING CurrentView:self];
    
}

#pragma -mark Net Delegate
- (void)onNetEngineResponse:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    
    [self removeHUDView:self];
    
    NSDictionary * entity_ = (NSDictionary *)entity;
    
    [self showMessage:entity_[@"result_info"]];
    
    if ([entity_[@"response_status"] integerValue] != 200) {
        
        return;
        
    }
    
    switch (tag) {
        case NET_GET_CAR_DOC_CHECK:
        {
            [self.navigationController popViewControllerAnimated:YES];
            
        }
            break;
            
        default:
            break;
    }
    
    
    
}
- (void)onNetEngineResponseFail:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    [self removeHUDView:self];
    
}

@end
